package com.yc.clouduser.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.clouduser.entity.Chat;
import com.yc.clouduser.mapper.ChatMapper;
import com.yc.clouduser.service.IChatService;
import com.yc.vcode.bean.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lzk
 * @since 2024-10-09
 */
@Service
public class ChatServiceImpl extends ServiceImpl<ChatMapper, Chat> implements IChatService {

    @Autowired
    ChatMapper chatMapper;

    @Override
    public Result one(int uid, int cid) {
        //删除聊天记录
        LambdaQueryWrapper<Chat> lqw1 = new LambdaQueryWrapper<>();
        lqw1.eq(Chat::getUid, uid);
        lqw1.eq(Chat::getCid, cid);
        chatMapper.delete(lqw1);
        return new Result(1, "删除成功", null);
    }

    @Override
    public Result all(int cid) {
        //删除聊天记录
        LambdaQueryWrapper<Chat> lqw1 = new LambdaQueryWrapper<>();
        lqw1.eq(Chat::getCid, cid);
        chatMapper.delete(lqw1);
        return new Result(1, "删除成功", null);
    }
}
